package meta.api.web.image.businesscontrol;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import meta.api.web.common.business.BusiCmnService;
import meta.api.web.file.businessinfo.FileInfo;

@Transactional
@Component
public class ImageMngBusiCtrl {

    @Autowired
    private BusiCmnService busiCmnService;

    @Transactional(rollbackFor = Exception.class)
    public void saveImg(FileInfo fileInfo, byte[] fileContent) {
        busiCmnService.saveFile(fileInfo, fileContent);
    }

    @Transactional(readOnly = true)
    public FileInfo getImgByFilename(String filename, String userId) {
        return busiCmnService.getFileByFilename(filename, userId);
    }

    @Transactional(readOnly = true)
    public boolean checkIsFileOwner(String filename, String userId) {
        return busiCmnService.checkIsFileOwner(filename, userId);
    }

    @Transactional(rollbackFor = Exception.class)
    public void deleteImgByFilename(String filename, String userId) {
        busiCmnService.deleteFileByFilename(filename, userId);
    }
}
